const defaultTheme = 'default'

const state = {
  theme: defaultTheme,
  themeList: [
    { id: 'default', name: '默认' },
    { id: 'light', name: '亮色' },
    { id: 'dark', name: '暗色' }
  ],
  navMenu: {
    isCollapse: false,
    showLogo: true
  }
}

const mutations = {
  SET_COLLAPSE: (state, stat) => {
    if (stat === undefined) {
      state.navMenu.isCollapse = !state.navMenu.isCollapse
    } else {
      state.navMenu.isCollapse = stat
    }
  },
  SET_THEME: (state, theme) => {
    if (theme === undefined) {
      state.theme = defaultTheme
    } else {
      state.theme = theme
    }
    import('@/assets/theme/' + state.theme + '.scss')
  }
}

const actions = {
  setCollapse({ commit }, stat) { commit('SET_COLLAPSE', stat) },
  setTheme({ commit }, stat) { commit('SET_THEME', stat) }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

